package com.gitee.denger.mybatis.example.ext.demo.controller;

import com.gitee.denger.mybatis.example.ext.demo.dao.ButtonMapper;
import com.gitee.denger.mybatis.example.ext.demo.entity.db.Button;
import com.gitee.denger.mybatis.example.ext.demo.entity.requ.ButtonRequ;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * button controller
 */
@Slf4j
@RestController
@RequestMapping("button")
public class ButtonController {

    /**
     * button数据库操作
     */
    @Autowired
    ButtonMapper buttonMapper;

    /**
     * 查询
     *
     * @param buttonRequ 查询参数
     * @return 符合条件的集合
     */
    @RequestMapping("select")
    public List<Button> list(ButtonRequ buttonRequ) {
        log.info(buttonRequ.toString());
        Example example = buttonRequ.toExample();
        return buttonMapper.selectByExample(example);
    }
}
